package com.qing.deep_in.springboot.chapter4.aspect.controller;

import com.qing.deep_in.springboot.chapter4.aspect.bean.User;
import com.qing.deep_in.springboot.chapter4.aspect.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author guoqf
 * @date 2021/9/11 22:05
 */
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/addUser")
    public String addUser(int id, String name, int code) {

        User user = new User(id, name, code);
        try {
            userService.addUser(user);
            return "success";
        } catch (Exception e) {
            e.printStackTrace();
            return "error";
        }

    }
}
